package com.example.sys.authority.dao;

import com.example.core.dao.BaseDao;
import com.example.sys.authority.model.SysAuthority;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SysAuthorityDao extends BaseDao<SysAuthority> {

    @Query("select fdElement.fdId from SysAuthority where fdModelName =:modelName and fdModelId =:modelId and fdKey =:key")
    public List<String> getModelAuthorityElements(@Param("modelName") String modelName, @Param("modelId") String modelId, @Param("key") int key) throws Exception;

    @Query("select fdModelId from SysAuthority where fdModelName =:modelName and fdElement.fdId in (:authIds)")
    public List<String> getModelIdAuthority(@Param("modelName")String modelName, @Param("authIds") List<String> authIds) throws Exception;
}
